package com.mojian.controller.points;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mojian.common.Result;
import com.mojian.entity.PointsRecord;
import com.mojian.entity.UserPoints;
import com.mojian.service.PointsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/points")
@Api(tags = "门户-积分管理")
public class PointsController {

    private final PointsService pointsService;

    @GetMapping("/info")
    @SaCheckLogin
    @ApiOperation(value = "获取用户积分信息")
    public Result<UserPoints> getUserPoints() {
        return Result.success(pointsService.getUserPoints());
    }

    @GetMapping("/records")
    @SaCheckLogin
    @ApiOperation(value = "获取用户积分记录")
    public Result<Page<PointsRecord>> getPointsRecords(
            @ApiParam(value = "页码", required = true) @RequestParam(defaultValue = "1") Integer pageNum,
            @ApiParam(value = "每页数量", required = true) @RequestParam(defaultValue = "10") Integer pageSize) {
        return Result.success(pointsService.getPointsRecords(pageNum, pageSize));
    }
} 